// pages/home/vocabulary/vocabulary.js
Page({

  /**
   * 页面的初始数据
   */
  
  data: {
    currentNavId: 0,
    keyword: "",
    categorys: [{
        id: 0,
        category: 'A'
      },
      {
        id: 1,
        category: 'B'
      },
      {
        id: 2,
        category: 'C'
      },
      {
        id: 3,
        category: 'D'
      },
      {
        id: 4,
        category: 'E'
      },
      {
        id: 5,
        category: 'F'
      },
      {
        id: 6,
        category: 'G'
      },
      {
        id: 7,
        category: 'H'
      },
      {
        id: 8,
        category: 'I'
      },
      {
        id: 9,
        category: 'J'
      },
      {
        id: 10,
        category: 'K'
      },
      {
        id: 11,
        category: 'L'
      },
      {
        id: 12,
        category: 'M'
      },
      {
        id: 13,
        category: 'N'
      },
      {
        id: 14,
        category: 'O'
      },
      {
        id: 15,
        category: 'P'
      },
      {
        id: 16,
        category: 'Q'
      },
      {
        id: 17,
        category: 'R'
      },
      {
        id: 18,
        category: 'S'
      },
      {
        id: 19,
        category: 'T'
      },
      {
        id: 20,
        category: 'U'
      },
      {
        id: 21,
        category: 'V'
      },
      {
        id: 22,
        category: 'W'
      },
      {
        id: 23,
        category: 'X'
      },
      {
        id: 24,
        category: 'Y'
      },
      {
        id: 25,
        category: 'Z'
      },
    ],

    words: [{
        category: 'A',
        list: [{
            pinyin: "āi ji āi hù",
            word: "挨家挨户",
            shiyi: "每家每户，户户不漏。挨，依次，顺次。",
          },
          {
            pinyin: "āi ji āi hù",
            word: "挨家挨户",
            shiyi: "每家每户，户户不漏。挨，依次，顺次。",
          }
        ]
      },
      {
        category: 'B',
        list: [{
            pinyin: "bà wáng bié jī",
            word: "霸王别姬",
            shiyi: "姬指西楚霸王项羽的宠妾虞姬。形容英雄末路的悲壮情景。现多比喻独断专行，脱离群众，最终垮台。",
          },
          {
            pinyin: "bái fà cāng cāng",
            word: "白发苍苍",
            shiyi: "苍苍灰白色。头发灰白。形容人的苍老。",
          }
        ]
      },
    ],
  },
  /* 把点击到的某一项 设为当前curNav   */
  switchRightTab: function (e) {
    let id = e.target.dataset.id;
    console.log(id);
    this.setData({
      curNav: id
    })
  },
  searchEvent: function (e) {
    console.log("*****>", e)
    console.log("====>", e.detail)
  },
  changeNav: function (e) {
    console.log("*****>", e)
    const navId = e.currentTarget.id;
    const tmpData = this.data.words.find(f => f.category == e.currentTarget.dataset.item.category).list
    console.log("*****>", tmpData)
    this.setData({
      currentNavId: navId,
      currentData: tmpData
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
      console.log(this.data.categorys)
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {
    // this.setData({
    //   currentData = words[0].list
    // })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})